<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			let stus = [];
			let index = 0;
			function load(){
				let xhr = new XMLHttpRequest;
				xhr.open("GET","stu.xml",false);
				xhr.send();
				let data = xhr.responseXML;
				stus = data.querySelectorAll("student");
				//stus = data.getElementsByTagName("student")
				document.querySelector("input").value = stus[0].getAttribute("sno");
				document.querySelector("input~input").value = stus[0].getAttribute("sname");
				//document.querySelectorAll("input")[1].value = stus[0].getAttribute("sname");
				
			}
			function fun(){
				index++;
				index = index%stus.length;
				document.querySelector("input").value = stus[index].getAttribute("sno");
				document.querySelector("input~input").value = stus[index].getAttribute("sname");
			}
		</script>
	</head>
	<body onload="load()">
		学号：<input type="text"  /><br>
		姓名：<input type="text"  />
		<button type="button" onclick="fun()">下一个</button>
	</body>
</html>
